package com.xuelang.pipeline.artifact.entry.resource;

import com.xuelang.pipeline.artifact.app.resource.ArtifactUserService;
import com.xuelang.pipeline.artifact.client.common.request.PageParam;
import com.xuelang.pipeline.artifact.client.common.result.ApiResult;
import com.xuelang.pipeline.artifact.client.common.result.PageRecord;
import com.xuelang.pipeline.artifact.client.resource.IArtifactUserService;
import com.xuelang.pipeline.artifact.client.resource.dto.ArtifactRoleUserDTO;
import com.xuelang.pipeline.artifact.client.resource.dto.ArtifactUserDTO;
import com.xuelang.pipeline.artifact.client.resource.dto.ArtifactUserQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 仓库用户web控制类
 *
 * @author xiwen.zxg
 * @since 2024/5/15
 */
@Slf4j
@RestController
@RequestMapping("/artifact-user")
public class ArtifactUserController implements IArtifactUserService {

    @Autowired
    private ArtifactUserService artifactUserService;

    @Override
    public ApiResult<PageRecord<ArtifactUserDTO>> pageArtifactUserList(PageParam<ArtifactUserQuery> dtoPageParam) {
        return ApiResult.success(artifactUserService.pageList(dtoPageParam));
    }

    @Override
    public ApiResult<List<ArtifactUserDTO>> conditionalArtifactUserList(ArtifactUserQuery artifactUserQuery) {
        return ApiResult.success(artifactUserService.list(artifactUserQuery));
    }

    @Override
    public ApiResult<Boolean> addArtifactUser(ArtifactUserDTO artifactUserDTO) {
        return ApiResult.success(artifactUserService.add(artifactUserDTO));
    }

    @Override
    public ApiResult<Boolean> updateArtifactUser(ArtifactUserDTO artifactUserDTO) {
        return ApiResult.success(artifactUserService.update(artifactUserDTO));
    }

    @Override
    public ApiResult<Boolean> deleteArtifactUser(String id) {
        return ApiResult.success(artifactUserService.delete(id));
    }

    @Override
    public ApiResult<ArtifactUserDTO> queryArtifactUser(String id) {
        return ApiResult.success(artifactUserService.query(id));
    }

    @Override
    public ApiResult<Boolean> updateArtifactRoleUser(ArtifactRoleUserDTO artifactRoleUserDTO) {
        return ApiResult.success(artifactUserService.updateArtifactRoleUser(artifactRoleUserDTO));
    }

    @Override
    public ApiResult<ArtifactRoleUserDTO> queryArtifactRoleUser(String artifactUuid) {
        return ApiResult.success(artifactUserService.queryArtifactRoleUser(artifactUuid));
    }


}